
package com.example.demo.gpss;

import api.GpssGrpc;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;

import java.util.concurrent.TimeUnit;


/**
 * @author Administrator
 */

public class GPSSConnector {

    private String gpssHost = "172.81.205.216";
    private int gpssPort = 50005;
    private ManagedChannel channel = null;
    private GpssGrpc.GpssBlockingStub bStub = null;

    public void establishGpssChannel(){
        channel = ManagedChannelBuilder.forAddress(gpssHost, gpssPort)
                .usePlaintext()
                .build();
        bStub = GpssGrpc.newBlockingStub(channel);
    }

    public void closeGpssChannel(int time) throws InterruptedException {
        channel.shutdown().awaitTermination(10, TimeUnit.SECONDS);
    }

    public GpssGrpc.GpssBlockingStub getGpssStub(){
        return bStub;
    }

}

